package cn.jinjimi.app.common;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import cn.jinjimi.app.AppManager;
import cn.jinjimi.app.R;
import cn.jinjimi.app.main.activity.LoginActivity;
import cn.jinjimi.app.main.dialog.CommAlertDialog;

/**
 *
 * @author m1
 * @date 14/12/12
 */
public class ErrorHandler {
    public static void preProcessError(final Context context) {
        if (context != null) {
            CommAlertDialog dialog = new CommAlertDialog(context, R.style.TransparentDialog);
            dialog.setTitle(context.getString(R.string.out_of_login));
            dialog.setRightBtn(context.getString(R.string.ok), new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(context,LoginActivity.class);
                    intent.putExtra("loseToken", true);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(intent);
                    AppManager.getInstance().finishAllActivity(null);
                }
            });
            dialog.setCancelable(false);
            dialog.showDialog(CommAlertDialog.Style.ONE_BUTTON);
        }
    }
}
